package com.slipper.codeless.resolve.update;


import com.slipper.util.Tool;

import java.util.ArrayList;
import java.util.List;

public class Update {
    private boolean insert = false; // true: 插入，false：更新
    private String tableName; // 更新的表名
    private String pkIdName; // 更新表的主键名
    private Object pkIdValue; // 更新表的主键值
    private List<UpdateField> updateFieldList = new ArrayList<>(); // 更新的字段

    public void setInsert(boolean insert) {
        this.insert = insert;
    }

    public boolean isInsert() {
        return insert || Tool.isBlank(this.getPkIdName()) || Tool.isBlank(this.getPkIdValue());
    }

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public String getPkIdName() {
        return pkIdName;
    }

    public void setPkIdName(String pkIdName) {
        this.pkIdName = pkIdName;
    }

    public Object getPkIdValue() {
        return pkIdValue;
    }

    public void setPkIdValue(Object pkIdValue) {
        this.pkIdValue = pkIdValue;
    }

    public List<UpdateField> getUpdateFieldList() {
        return updateFieldList;
    }

    public void setUpdateFieldList(List<UpdateField> updateFieldList) {
        this.updateFieldList = updateFieldList;
    }

    public void addUpdateField(UpdateField updateField) {
        this.updateFieldList.add(updateField);
    }
}
